use std::sync::Arc;
use std::time::Duration;
use reqwest::{blocking, Url};
use serde::Deserialize;
use threadpool::ThreadPool;

mod main1;

fn main() {
    let pool = ThreadPool::new(3);
    let client = Arc::new(blocking::Client::builder()
        .connect_timeout(Duration::from_secs(20))
        .timeout(Duration::from_secs(50)).build().expect("ssss"));
    for i in 0..3 {
        let client = Arc::clone(&client);
        pool.execute(move || {
            let mut url = String::from("http://127.0.0.1:4000/demo/");
            url.push_str(format!("{i}").as_ref());
            match client.get(url).send() {
                Ok(_) => println!("请求id {i} 请求成功！"),
                Err(e) => println!("{}",e),
            }
        });
    }
    pool.join();
    println!("程序运行结束");
}
